#!/bin/bash 

awk '{print $2,$1,$6}' 04_interface.dat > file_utm.txt #amplitude
ZONE=19
MERIDIAN=`echo $ZONE | awk '{print int((('$ZONE'*6)-180)-3)}'`
UTM_REGION=`echo $MERIDIAN| awk '{printf("%i/%i/%i/%i\n", $1-3,$1+3,-90,0)}' `
awk '{if(NR>=1) printf("%.12lg %.12lg %.5f \n",$2,$1,$3)}' file_utm.txt | \
gmt mapproject -V -I -Ju$ZONE/1:1 -R$UTM_REGION -C0/0 -F | \
awk '{printf("%.12lg %.12lg %.5f \n",$1,$2,$3)}' > file.latlong
awk '{for(i=0;i<3;i++)print}' file.latlong > tmp.txt
awk 'NR>1{print $0}' tmp.txt > tmp1.txt
awk '{if ((NR % 3) == 1) sub($1, "> -Z", $1); print $0}' tmp1.txt > tmp2.txt
awk '{if ((NR % 3) == 1) sub($3, "", $3); print $0}' tmp2.txt > tmp3.txt
sed 's/ \{2,\}//g' tmp3.txt > tmp4.txt
awk '{print $1,$2}' tmp4.txt > tmp5.txt
sed '$d' tmp5.txt > tmp6.txt
sed '$d' tmp6.txt > tmp7.txt



